<template>
  <div class="main">
    <h2 class="user-title"><span>售后管理</span></h2>
    <div class="table-content">
      <div class="table-header">
        <span>服务编号</span><span>订单编号</span><span>商品</span><span>供应商</span><span>申请时间</span><span>全部状态</span><span>操作</span>
      </div>
      <div class="table-tbody">
        <div class="table-list" v-if="productList.length > 0" v-for="(item, index) in productList" :key="index">
          <div class="list-num">{{item.saleafterId}}</div>
          <p class="list-num">{{item.orderId}}</p>
          <div class="product">
            <div class="product-img"><img :src="item.productCover" width="100%" height="100%"></div>
            <div class="product-name">
              <p>{{item.name}}</p>
              <p>规格:{{item.attributeName}}</p>
            </div>
          </div>
          <p class="supplier">{{item.storeName}}</p>
          <p class="supplier">{{item.applyTime}}</p>
          <p class="status">{{afterSaleTypes.Types[item.orderStatus]}}</p>
          <p class="check"><span @click="check(item.saleafterId)">查看详情</span></p>
        </div>
        <div class="table-no" v-if="productList.length === 0">
          暂无售后订单
        </div>
      </div>
    </div>
    <v-pagination v-if="total" :pg="page" :size="pageSize" :total="total" @page-change="pageChange"></v-pagination>
  </div>
</template>

<script>
import vPagination from '@/components/public/pagination'
import { afterSaleTypes } from '@/util/enums'
export default {
  data () {
    return {
      productList: [],
      page: 1,
      pageSize: 10,
      total: 0,
      afterSaleTypes: afterSaleTypes
    }
  },
  components: {
    vPagination
  },
  mounted () {
    this.getData()
  },
  methods: {
    getData () {
      this.$http.post(this.$api + '/pc/orderSaleafter/getSaleafterList', {
        page: this.page,
        pageSize: this.pageSize
      }).then(res => {
        if (res.responseCode === '0000') {
          this.productList = res.data.list
          this.total = res.data.total
        }
      })
    },
    // 切换页面
    pageChange (pg) {
      this.page = pg
      this.getData()
    },
    check (saleafterId) {
      this.$router.push('/user/afterSalesDetail?saleafterId=' + saleafterId)
    }
  }
}
</script>

<style lang="scss" scoped>
@import '@/assets/scss/basic.scss';
  .table-content{
    .table-header{
      border: 1px solid $border_color;
      font-size: $fz_14;
      color: $f_main;
      background: #ffffff;
      margin: 16px 0 20px;
      height: 30px;
      line-height: 30px;
      span{
        text-align: center;
        display: inline-block;
      }
      span:first-child, span:nth-child(2){
        width: 120px;
      }
      span:nth-child(3){
        width: 407px;
      }
      span:nth-child(4), span:nth-child(5){
        width: 111px;
      }
      span:nth-child(6) {
        width: 96px;
      }
      span:nth-child(7) {
        width: 76px;
      }
    }
    .table-tbody{
      background: #ffffff;
      border: 1px solid $border_color;
      border-bottom: 0;
      font-size: $fz_14;
      .table-list{
        display: flex;
        height: 160px;
        border-bottom: 1px solid $border_color;
        .list-num{
          display: flex;
          align-items: center;
          width: 120px;
          height: 160px;
          border-right: 1px solid $border_color;
          padding: 0 12px;
          color: $f_normal;
          word-break:break-word;
        }
        .product{
          width: 408px;
          border-right: 1px solid $border_color;
          padding: 28px 35px 23px 15px;
          display: flex;
          .product-img{
            box-sizing: border-box;
            width: 111px;
            height: 111px;
            border: 1px solid $border_color;
            margin-right: 12px;
          }
          .product-name{
            p:first-child{
              padding-top: 15px;
              color: $f_main;
            }
            p:nth-child(2){
              color: $f_normal;
              margin-top: 15px;
            }
          }
        }
        .supplier{
          width: 112px;
          padding: 0 15px;
          border-right: 1px solid $border_color;
          display: flex;
          align-items: center;
        }
        .status{
          width: 96px;
          text-align: center;
          padding: 0 15px;
          border-right: 1px solid $border_color;
          display: flex;
          align-items: center;
        }
        .check{
          width: 76px;
          display: flex;
          align-items: center;
          padding: 0 10px;
          span{
            cursor: pointer;
            color: $font-blue;
            border-bottom: 1px solid transparent;
            &:hover{
              border-bottom: 1px solid $font-blue;
            }
          }
        }
      }
      .table-no{
        height: 160px;
        border-bottom: 1px solid $border_color;
        line-height: 160px;
        text-align: center;
      }
    }
  }
</style>
